{% extends "common/layout.html" %}

{% block content %}

    <script>
        function loadindex() {
            var t =
            {{ t }}

            if (t == 2) {
                $('a[href="#two"]').tab('show');
            } else if (t == 3) {
                $('a[href="#three"]').tab('show');
            } else {
                $('a[href="#one"]').tab('show');
            }

        }

        window.onload = loadindex;


    </script>

    <div class="row bg-primary">
        <div class="col-sm-10 col-sm-offset-1">
            <h2>移动办公平台数据管理系统</h2>
            <h6>Mobile office platform data management system</h6>
        </div>
    </div>

    <div class="row">
        <!-- Nav tabs -->
        <div class="col-sm-10 col-sm-offset-1" style="margin-top: 30px">
            <div class="row time-pick">

                <div class='col-sm-2 '>
                    <div class="form-group">
                        <label>选择开始时间：</label>
                        <!--指定 date标记-->
                        <div class='input-group date' id='datetimepickers'>
                            <input type='text' class="form-control" name="starttime" id="starttime"
                                   value="{{ stime }}"/>
                            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
                        </div>
                    </div>
                </div>


                <div class='col-sm-2'>
                    <div class="form-group">
                        <label>选择结束时间：</label>
                        <!--指定 date标记-->
                        <div class='input-group date' id='datetimepickere'>
                            <input type='text' class="form-control" name="endtime" id="endtime"
                                   value="{{ etime }}"/>
                            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
                        </div>
                    </div>
                </div>


                <div class='col-sm-1'>
                    <div class="form-group">
                        <label></label>
                        <button type="submit" class="btn btn-primary btn-sm btn-block do-pickup "
                                id="dopicker">
                            搜索
                        </button>
                    </div>
                    <script type="text/javascript">
                        {#搜索#}
                        var donepicker = {
                            init: function () {
                                this.eventBind()
                            },
                            eventBind: function () {
                                $(".do-pickup").click(function () {
                                    var city = "{{ current_user.city }}";
                                    var starttime = $(".time-pick input[name=starttime]").val();
                                    var endtime = $(".time-pick input[name=endtime]").val();
                                    var urlindex = common_ops.buildUrl("/thing/thingsearch?starttime=") + starttime + "&endtime=" + endtime + "&city=" + city + "&t=2";
                                    document.location.href = urlindex;


                                });
                            }
                        };
                        $(document).ready(function () {
                            donepicker.init();
                        });
                        {#日期#}
                        var mydata = new Date();
                        var lastM = new Date(new Date().setMonth(new Date().getMonth() - 1));
                        {#var mudata2 = mydata.setMonth(mydata.getMonth() - 1)#}
                        $(function () {
                            var picker1 = $('#datetimepickers').datetimepicker({
                                format: 'YYYY-MM-DD',
                                locale: moment.locale('zh-cn'),
                                defaultDate: lastM.toLocaleDateString()
                                //minDate: '2016-7-1'
                            });
                            var picker2 = $('#datetimepickere').datetimepicker({
                                format: 'YYYY-MM-DD',
                                locale: moment.locale('zh-cn'),
                                defaultDate: mydata.toLocaleDateString()
                            });
                            //动态设置最小值
                            picker1.on('dp.change', function (e) {
                                picker2.data('DateTimePicker').minDate(e.date);
                            });
                            //动态设置最大值
                            picker2.on('dp.change', function (e) {
                                picker1.data('DateTimePicker').maxDate(e.date);
                            });
                        });
                    </script>
                </div>


                <div class='col-sm-1'>
                    <div class="form-group">
                        <label></label>
                        <button type="submit" class="btn btn-success btn-sm btn-block do-exportly "
                                id="doexportly">
                            导出领用
                        </button>


                    </div>

                    <script type="text/javascript">
                        var exporterly = {
                            init: function () {
                                this.eventBind()
                            },
                            eventBind: function () {
                                $(".do-exportly").click(function () {
                                    var starttime = $(".time-pick input[name=starttime]").val();
                                    var endtime = $(".time-pick input[name=endtime]").val();
                                    var urlindex = common_ops.buildUrl("/thing/exportly?starttime=") + starttime + "&endtime=" + endtime + "&city=" + "{{ current_user.city }}";
                                    document.location.href = urlindex;

                                });
                            }
                        };
                        $(document).ready(function () {
                            exporterly.init();
                        });

                    </script>
                </div>


                <div class='col-sm-1'>
                    <div class="form-group">
                        <label></label>

                        <button type="submit" class="btn btn-success btn-sm btn-block do-exportrk "
                                id="doexportrk">
                            导出入库
                        </button>
                    </div>

                    <script type="text/javascript">

                        var exporterrk = {
                            init: function () {
                                this.eventBind()
                            },
                            eventBind: function () {
                                $(".do-exportrk").click(function () {
                                    var starttime = $(".time-pick input[name=starttime]").val();
                                    var endtime = $(".time-pick input[name=endtime]").val();
                                    var urlindex = common_ops.buildUrl("/thing/exportrk?starttime=") + starttime + "&endtime=" + endtime + "&city=" + "{{ current_user.city }}";
                                    document.location.href = urlindex;

                                });
                            }
                        };
                        $(document).ready(function () {
                            exporterrk.init();
                        });
                    </script>
                </div>


            </div>


            <ul class="nav nav-tabs" role="tablist">

                {% if thingdoing %}
                    <li id="tabone" role="presentation" class="active">
                        <a href="#one" aria-controls="one" role="tab" data-toggle="tab" onclick="">未验证数据
                            <span class="badge"></span>
                        </a>
                    </li>
                {% endif %}

                {% if thingdone %}
                    <li id="tabtwo" role="presentation">
                        <a href="#two" aria-controls="two" role="tab" data-toggle="tab">领用数据
                            <span class="badge"></span>
                        </a>
                    </li>

                    <li id="tabthree" role="presentation">
                        <a href="#three" aria-controls="three" role="tab" data-toggle="tab">入库数据
                            <span class="badge"></span>
                        </a>
                    </li>
                {% endif %}


            </ul>


            <!-- Tab panes -->
            <div class="tab-content">

                <div role="tabpanel" class="tab-pane active" id="one">
                    <div class="row">
                        <div class="col-sm-12">
                            <row class="data-table">
                                <table class="table table-bordered table-hover">
                                    <tr>
                                        <th class="info">领用单号</th>
                                        <th class="info">品类</th>
                                        <th class="info">名称</th>
                                        <th class="info">型号</th>
                                        <th class="info">数量</th>
                                        <th class="info">领用人</th>
                                        <th class="info">领用公司</th>
                                        <th class="info">领用部门</th>
                                        <th class="info">领用项目</th>
                                        <th class="info">功能</th>

                                    </tr>
                                    {% for item in thingdoing %}
                                        <tr>
                                            <th>{{ item.sn }}</th>
                                            <th>{{ item.classone }}</th>
                                            <th>{{ item.classtwo }}</th>
                                            <th>{{ item.classthree }}</th>
                                            <th>{{ item.num }}</th>
                                            <th>{{ item.creater.nickname }}</th>
                                            <th>{{ item.creater.company }}</th>
                                            <th>{{ item.creater.department }}</th>
                                            <th>{{ item.project | deletenone }}</th>
                                            <th>
                                                <a href="{{ buildUrl('/thing/changethingmark') }}?id={{ item.id }}&mark=0&type=2"
                                                   class="btn btn-danger" style="margin-left: 50px">删除</a>
                                            </th>
                                        </tr>

                                    {% endfor %}
                                </table>
                            </row>

                            {% if pages1 %}
                                <div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <ul class="pagination pull-right">
                                                {% if pages1.is_prev == 1 %}
                                                    <li>
                                                        <a href="{{ pages1.url }}&p={{ pages1.current - 1 }}&t=1"
                                                           aria-label="Previous">
                                                            <span aria-hidden="true">上一页</span>
                                                        </a>
                                                    </li>
                                                {% endif %}

                                                {% for idx in pages1.range %}
                                                    <li {% if pages1.current == idx %} class="active" {% endif %}  ><a
                                                            href="{{ pages1.url }}&p={{ idx }}&t=1">{{ idx }}</a></li>
                                                {% endfor %}
                                                {% if pages1.is_next == 1 %}
                                                    <li>
                                                        <a href="{{ pages1.url }}&p={{ pages1.current + 1 }}&t=1"
                                                           aria-label="Next">
                                                            <span aria-hidden="true">下一页</span>
                                                        </a>
                                                    </li>
                                                {% endif %}
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            {% endif %}

                        </div>
                    </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="two">
                    <div class="row">
                        <div class="col-sm-12">
                            <row class="data-table">
                                <table class="table table-bordered table-hover">
                                    <tr>
                                        <th class="info">领用单号</th>
                                        <th class="info">品类</th>
                                        <th class="info">名称</th>
                                        <th class="info">型号</th>
                                        <th class="info">数量</th>
                                        <th class="info">领用人</th>
                                        <th class="info">领用公司</th>
                                        <th class="info">领用部门</th>
                                        <th class="info">领用项目</th>
                                    </tr>
                                    {% for item in thingdone %}
                                        <tr>
                                            <th>{{ item.sn }}</th>
                                            <th>{{ item.classone }}</th>
                                            <th>{{ item.classtwo }}</th>
                                            <th>{{ item.classthree }}</th>
                                            <th>{{ item.num }}</th>
                                            <th>{{ item.creater.nickname }}</th>
                                            <th>{{ item.creater.company }}</th>
                                            <th>{{ item.creater.department }}</th>
                                            <th>{{ item.project | deletenone }}</th>
                                        </tr>

                                    {% endfor %}
                                </table>
                            </row>
                            {% if pages2 %}
                                <div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <ul class="pagination pull-right">
                                                {% if pages2.is_prev == 1 %}
                                                    <li>
                                                        <a href="{{ pages2.url }}&p={{ pages2.current - 1 }}&t=2"
                                                           aria-label="Previous">
                                                            <span aria-hidden="true">上一页</span>
                                                        </a>
                                                    </li>
                                                {% endif %}

                                                {% for idx in pages2.range %}
                                                    <li {% if pages2.current == idx %} class="active" {% endif %}  ><a
                                                            href="{{ pages2.url }}&p={{ idx }}&t=2">{{ idx }}</a></li>
                                                {% endfor %}
                                                {% if pages2.is_next == 1 %}
                                                    <li>
                                                        <a href="{{ pages2.url }}&p={{ pages2.current + 1 }}&t=2"
                                                           aria-label="Next">
                                                            <span aria-hidden="true">下一页</span>
                                                        </a>
                                                    </li>
                                                {% endif %}
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            {% endif %}

                        </div>
                    </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="three">
                    <div class="row">


                        <div class="col-sm-12">

                            <row class="data-table">
                                <table class="table table-bordered table-hover">
                                    <tr>
                                        <th class="info">领用单号</th>
                                        <th class="info">品类</th>
                                        <th class="info">名称</th>
                                        <th class="info">型号</th>
                                        <th class="info">数量</th>
                                        <th class="info">领用人</th>
                                        <th class="info">领用公司</th>
                                        <th class="info">领用部门</th>
                                        <th class="info">领用项目</th>

                                    </tr>
                                    {% for item in rk %}
                                        <tr>
                                            <th>{{ item.sn }}</th>
                                            <th>{{ item.classone }}</th>
                                            <th>{{ item.classtwo }}</th>
                                            <th>{{ item.classthree }}</th>
                                            <th>{{ item.num }}</th>
                                            <th>{{ item.creater.nickname }}</th>
                                            <th>{{ item.creater.company }}</th>
                                            <th>{{ item.creater.department }}</th>
                                            <th>{{ item.project | deletenone }}</th>

                                        </tr>

                                    {% endfor %}
                                </table>
                            </row>
                            {% if pages3 %}
                                <div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <ul class="pagination pull-right">
                                                {% if pages3.is_prev == 1 %}
                                                    <li>
                                                        <a href="{{ pages3.url }}&p={{ pages3.current - 1 }}&t=3"
                                                           aria-label="Previous">
                                                            <span aria-hidden="true">上一页</span>
                                                        </a>
                                                    </li>
                                                {% endif %}

                                                {% for idx in pages3.range %}
                                                    <li {% if pages3.current == idx %} class="active" {% endif %}  ><a
                                                            href="{{ pages3.url }}&p={{ idx }}&t=3">{{ idx }}</a></li>
                                                {% endfor %}
                                                {% if pages3.is_next == 1 %}
                                                    <li>
                                                        <a href="{{ pages3.url }}&p={{ pages3.current + 1 }}&t=3"
                                                           aria-label="Next">
                                                            <span aria-hidden="true">下一页</span>
                                                        </a>
                                                    </li>
                                                {% endif %}
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            {% endif %}
                        </div>
                    </div>
                </div>


            </div>

        </div>
    </div>



{% endblock %}


{% block js %}
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
{% endblock %}


